package ch.selise.archtool.ui.states;

import java.awt.EventQueue;
import java.util.List;

import javax.swing.JFrame;

import ch.selise.archtool.lib.HouseBuilder;
import ch.selise.archtool.lib.HouseBuildingCompany;
import ch.selise.archtool.lib.builders.SimpleHouseBuilder;
import ch.selise.archtool.lib.product.House;
import ch.selise.archtool.ui.ArchWindow;
import ch.selise.archtool.ui.Context;

public class BuilderChooseState implements State {

	private Context context;
	private JFrame frame;
	public BuilderChooseState(Context context)
	{
		this.context =context;
	}
	@Override
	public void process() {
		context.doneBuildingHouse(((ArchWindow)frame).getController().getHouse());
		frame.setVisible(false);
	}

	@Override
	public void cancel() {
		System.out.println("canceling " + this.getClass());
	}
	@Override
	public void show() {
		if(frame == null)
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new ArchWindow(context);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		
		else{
			frame.setVisible(true);
		}
	}

}
